/*
 * User: ophir
 * Date: Sep 8, 2008
 * Time: 12:04:59 AM
 */
package org.conann;

import static com.google.common.base.Preconditions.checkNotNull;
import net.jcip.annotations.Immutable;
import org.conann.metadata.BeanMD;

import java.lang.annotation.Annotation;
import java.util.Set;

@Immutable
public class Stereotype {

    private final Class<? extends Annotation> annotationType;
    private final BeanMD beanMD;

    public Stereotype(Class<? extends Annotation> annotationType) {
        checkNotNull(annotationType);
        this.annotationType = annotationType;
        beanMD = new BeanMD(annotationType);
    }

    public Set<Annotation> getBindingTypes() {
        return beanMD.getBindingTypes();
    }

    public Class<? extends Annotation> getScopeType() {
        return beanMD.getScopeType();
    }

    public Class<? extends Annotation> getDeploymentType() {
        return beanMD.getDeploymentType();
    }

    public BeanMD getComponentMD() {
        return beanMD;
    }

    @SuppressWarnings({"AccessingNonPublicFieldOfAnotherObject"})
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Stereotype that = (Stereotype) o;
        return annotationType.equals(that.annotationType);
    }

    @Override
    public int hashCode() {
        return annotationType.hashCode();
    }
}